import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
import choiceCityCom from "@/page/choiceCityCom/choiceCityCom.vue";
import searchPositionCom from "@/page/searchPositionCom/searchPositionCom.vue";
import homeCom from "@/page/homeCom/homeCom.vue";
import shopCom from "@/page/shopCom/shopCom.vue";
import mineCom from "@/page/mineCom/mineCom.vue";
import App from "@/App.vue";
import loginCom from "@/page/loginCom/loginCom.vue";
import searchShopCom from "@/page/searchShopCom/searchShopCom.vue";

Vue.use(VueRouter)

const routes: Array<RouteConfig> = [
  {
    path: '/',
    component: App,
    children: [
      {
        path: '/choiceCity',
        component: choiceCityCom
      },
      {
        path: '/searchPosition',
        component: searchPositionCom
      },
      {
        path: '/searchPosition/:cityid',
        component: searchPositionCom
      },
      {
        name: 'home',
        path: '/home',
        component: homeCom,
        meta: { keepAlive: true },
      },
      //商铺详情页
      {
        name: 'shop',
        path: '/shop',
        component: shopCom,
        // children: [{
        //   path: 'foodDetail', //食品详情页
        //   component: foodDetail,
        // }, {
        //   path: 'shopDetail', //商铺详情页
        //   component: shopDetail,
        //   children: [{
        //     path: 'shopSafe', //商铺安全认证页
        //     component: shopSafe,
        //   }, ]
        // }]
      },
      {
        name: 'searchShop',
        path: '/searchShop',
        component: searchShopCom,
      },
      {
        name:'mine',
        path: '/mine',
        component: mineCom,
      },
      {
        name:'login',
        path: '/login',
        component: loginCom,
      },
      // 重定向项目访问/时定向到主页
      {
        path: '/',
        redirect: '/home',
      }
    ]
  }]
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
